ISCPropertyBag Interface

The following table contains information on the ISCPropertyBag interface:

Signature

Description

Valid Arguments

long Count()

Returns the number of properties

None

VARIANT Value(VARIANT Property)

Retrieves the indicated property in the bag

Property:

  • VT_BSTR � Name of property. Value of the property with the given name in the property bag.
  • VT_I4 � Zero-based property index. Value of the property with the given index in the property bag.

BSTR Name(long

PropertyIdx)

Retrieves the indicated property name with the given index. Range of indices is from 0 to size-1.

None

Example 3

The following example illustrates how to use the API as an add-in tool to iterate through the open models using C++. The example uses the Application object created in Example 1:

void IteratePersistenceUnits(ISCApplicationPtr & scAppPtr)
{   
    ISCPersistenceUnitCollectionPtr scPUnitColPtr;
    scPUnitColPtr = scAppPtr->GetPersistenceUnits();
    
    ISCPersistenceUnitPtr scPUnit = 0;
    long lCnt = scPUnitColPtr->GetCount();
    
    for(long i = 0; i < lCnt; i++)
    {   
        scPUnit = scPUnitColPtr->GetItem(i);
        CString csName = scPUnit->GetName();   // name of model
        ISCPropertyBagPtr scPropBag = scPUnit->GetPropertyBag("Locator;Active  Model");
        long index = 0;
        CComVariant vPathName = scPropBag->GetValue(ColeVariant(index));  // full
        //path of model       
        index = 1;
        CComVariant cActiveModel = scPropBag->GetValue(COleVariant(index)); // true if active model
        // …
    }
}

The following example illustrates how to use the API as an add-in tool to iterate through the open models using Visual Basic .NET. The example uses the Application object created in Example 1:

Public Sub IteratePersistenceUnits(ByRef scApp As SCAPI.Application)
      Dim scPersistenceUnitCol as SCAPI.PersistenceUnits    
      
      Dim numUnits As Integer
      Dim scPUnit As SCAPI.PersistenceUnit
      
      scPersistenceUnitCol = scApp.PersistenceUnits
      
      ' Count open units
      numUnits = scPersistenceUnitCol.Count
      If (numUnits > 0) Then
	For Each scPUnit In scPersistenceUnitCol
	      Dim propBag As SCAPI.PropertyBag
                  
	      propBag = scPUnit.PropertyBag("Locator")
	      Console.WriteLine( persUnit.Name )   ' name of model
	      Console.WriteLine( propBag.Value(0)) ' full path of model
	       ' …
	 Next
      End If
End Sub